﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/BaseMaster/DetailPages.Master" AutoEventWireup="true" CodeBehind="AuthorizeMenu.aspx.cs" Inherits="Liu_Project.Web.Admin.Pages.Personal.EntRole.AuthorizeMenu" %>

<asp:Content ID="Content1" ContentPlaceHolderID="DetailTitle" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="DetailHead" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="DetailContent" runat="server">
    <div class="layui-card">
        <div style="padding: 10px; height: 100%; overflow: auto;">
            <ul id="menuTree" class="dtree" data-id="0"></ul>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="DetailScript" runat="server">
    <script>
        // 绑定节点点击事件
        //layui.dtree.on("node('menuTree')", function (obj) {
        //    MenuTree.clickNodeCheckbar(obj.param.nodeId);// 点击节点选中复选框
        //    var params = layui.dtree.getCheckbarJsonArrParam("menuTree");
        //    layui.layer.msg(JSON.stringify(params));
        //});

        var MenuTree;
        function setData(type, Id) {
            // 初始化树
            MenuTree = layui.dtree.render({
                elem: "#menuTree",
                url: bootPATH + "Admin/Handler/Personal/EntRoleHand.ashx", // 使用url加载（可与data加载同时存在）
                dataStyle: "layuiStyle",  //使用layui风格的数据格式
                dataFormat: "list",  //配置data的风格为list
                request: { act: "LoadList", Type: type, Id: Id },
                response: { message: "msg", statusCode: 1, treeId: "MenuId", parentId: "ParentId", title: "MenuName" },//修改response中返回数据的定义
                initLevel: 1,
                menubar: true,
                menubarTips: {
                    group: ["moveDown", "moveUp", "refresh", "checkAll", "unCheckAll", "invertAll", "searchNode"], //按钮组
                },
                checkbar: true, //开启复选框
                checkbarType: "no-all",
                checkbarData: "halfChoose",
                line: true, // 显示树线
                done: function (res, $ul, first) {
                    if (first) {
                        // 反选半选状态
                        layui.dtree.initNoAllCheck("menuTree");
                    }
                }
            });

        }

        function Save(type, Id, index) {
            var nodes = layui.dtree.getCheckbarNodesParam("menuTree");
            if (nodes.length == 0) {
                layer.msg('请选择数据后,再操作.');
                return;
            }

            top.layer.load(1);
            GetObjectInfoFunction_Async("Admin/Handler/Personal/EntRoleHand.ashx", {
                "act": "SaveMenuCapability", Type: type, "Id": Id, "Data": JSON.stringify(nodes)
            }, function (result) {
                parent.layer.close(index);
                top.layer.msg('保存成功');
            })
        }

    </script>
</asp:Content>
